package cn.edu.cdp.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

public class MyBatisConfig {
    @Bean
    public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource) {
        SqlSessionFactoryBean s = new SqlSessionFactoryBean();
        s.setTypeAliasesPackage("cn.edu.cdp.domain");
        s.setDataSource(dataSource);
        return s;
    }

    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer m = new MapperScannerConfigurer();
        m.setBasePackage("cn.edu.cdp.dao");
        return m;
    }
}
